/*
 * Panograph.h
 *
 *  Created on: 02/09/2011
 *      Author: solnox
 */

#ifndef PANOGRAPH_H_
#define PANOGRAPH_H_
#include "opencv2/opencv.hpp"
#include "AnalyzedImage.h"

class Panograph {
public:

	Panograph(std::string input_path);
	virtual ~Panograph();
	void buildPanograph(std::vector<cv::Mat*> images);
	void benchmarkPanograph(std::string benchmark_path);

private:std::string int2string(int number);
	void getMinMaxVectors(std::vector< cv::Vec2d > &corners, cv::Vec2d & min_vec, cv::Vec2d & max_vec);
	void matches2points(const std::vector<cv::KeyPoint>& train, const std::vector<cv::KeyPoint>& query,
			const std::vector<cv::DMatch>& matches, std::vector<cv::Point2f>& pts_train,
			std::vector<cv::Point2f>& pts_query);
	void warpKeyPoints(std::vector<cv::KeyPoint> & input_kps,std::vector<cv::KeyPoint> & output_kps, cv::Mat & H);
	void shiftKeyPoints(std::vector<cv::KeyPoint> & kps, cv::Vec2i shift);
	void calculateTransitionWeighting(const cv::Mat & big_img_mask, const cv::Mat & overlap_mask, cv::Mat  & weight_img);
	void stitchSmoothly(const cv::Mat & big_img_mask, const cv::Mat & big_pano_mask, const cv::Mat & overlap_mask, const cv::Mat &  big_warped_img, const cv::Mat &  shifted_pano, cv::Mat & out_img);
	void stitchAveraging(const cv::Mat & big_img_mask, const cv::Mat & big_pano_mask, const cv::Mat & overlap_mask, const cv::Mat &  big_warped_img, const cv::Mat &  shifted_pano, cv::Mat & out_img);
	AnalyzedImage panograph_;
	//cv::Mat panograph_;
	//cv::Mat bw_panograph_;
	//bool is_bw_pano_up2date_;
	int min_matches_ ;
	int number_of_images_in_panograph_;
	//std::vector<cv::KeyPoint> keypoints_;
	//cv::Mat desc_;
	std::string input_path_;
	std::vector<AnalyzedImage> images2add_;
};

#endif /* PANOGRAPH_H_ */
